'''
Created on 28/07/2010

@author: eh01
'''
import unittest
from adaptor.services.adaptor_home_service import AdaptorHomeService
from datastore.spaces import Spaces
from datastore.uri import Uri


class AdaptorHomeServiceTest(unittest.TestCase):


    def setUp(self):
        pass


    def tearDown(self):
        pass

    def test_cb_start(self):
        spaces = Spaces()
        adaptor_home_service = AdaptorHomeService(spaces, uri=Uri())
        adaptor_home_service.cb_start(None, None, None)
        self.assertEqual(adaptor_home_service.cb_adaptor_home, spaces.process[Uri('external:adaptor')][0])
        
    def test_cb_adaptor_home_get(self):
        adaptor_home_service = AdaptorHomeService(spaces=Spaces(), uri=Uri())
        res = adaptor_home_service.cb_adaptor_home(None, Spaces.ACTION_GET, None)
        self.assertEqual(Uri('term:eplanning/adaptor/home/get/data'), res.get_type())
        self.assertEqual(AdaptorHomeService.SPEAR_ADAPTOR_HEADER, res.h1_header)
        
    def test_cb_adaptor_home_exits(self):
        adaptor_home_service = AdaptorHomeService(spaces=Spaces(), uri=Uri())
        exists = adaptor_home_service.cb_adaptor_home(None, Spaces.ACTION_EXISTS, None)
        self.assertTrue(exists)

    def test_cb_adaptor_home_put(self):
        adaptor_home_service = AdaptorHomeService(spaces=Spaces(), uri=Uri())
        uri = adaptor_home_service.cb_adaptor_home(None, Spaces.ACTION_PUT, None)
        self.assertEqual(None, uri)
        
    def test_cb_adaptor_home_delete(self):
        adaptor_home_service = AdaptorHomeService(spaces=Spaces(), uri=Uri())
        ret = adaptor_home_service.cb_adaptor_home(None, Spaces.ACTION_DELETE, None)
        self.assertEqual(None, ret)
        
    def test_cb_adaptor_home_update(self):
        adaptor_home_service = AdaptorHomeService(spaces=Spaces(), uri=Uri())
        uri = adaptor_home_service.cb_adaptor_home(None, Spaces.ACTION_UPDATE, None)
        self.assertEqual(None, uri)
        
    def test_cb_adaptor_home_remove(self):
        adaptor_home_service = AdaptorHomeService(spaces=Spaces(), uri=Uri())
        res = adaptor_home_service.cb_adaptor_home(None, Spaces.ACTION_REMOVE, None)
        self.assertEqual(None, res)
        
    def test_cb_adaptor_home_find(self):
        adaptor_home_service = AdaptorHomeService(spaces=Spaces(), uri=Uri())
        lst = adaptor_home_service.cb_adaptor_home(None, Spaces.ACTION_FIND, None)
        self.assertEqual(None, lst)
        
if __name__ == "__main__":
    #import sys;sys.argv = ['', 'Test.test_cb_adaptor_home']
    unittest.main()